//导入 axios 的封装对象
import {request} from '@utils/http'
import React from 'react';
import type { HospitalSetItem, ReqAddHospitalSetParams, ReqHospitalSetListParams, ReqHospitalSetListResponse, ReqUpdateHospitalSetParams } from './model/hospitalSetTypes'

/**
 * 批量获取医院设置的信息
 * @param param0 ReqHospitalSetListParams  请求参数对象
 * @returns  Promise<ReqHospitalSetListResponse>
 */
export function reqGetHospitalSetList({
  page, 
  limit, 
  hosname, 
  hoscode
}:ReqHospitalSetListParams){
  return request.get<any, ReqHospitalSetListResponse>(
    //URL 参数
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    //query 参数
    {
      params: {
        hosname: hosname,
        hoscode: hoscode
      }
    }
  )
}

/**
 * 新增医院
 * @param hospitalSet 医院数据
 * @returns Promise<null>
 */
export function reqAddHospitalSetItem(hospitalSet: ReqAddHospitalSetParams){
  return request.post<any, null>('/admin/hosp/hospitalSet/save', hospitalSet)
}

/**
 * 通过 id 获取单个医院设置信息
 * @param id  医院设置信息的 ID
 * @returns Promise<HospitalSetItem>
 */
export function reqGetHospitalSetItem(id: string){
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}

/**
 * 更新单个医院的信息
 * @param hospitalSet 完整的医院设置信息对象
 * @returns Promise<null>
 */
export function reqUpdateHospitalSet(hospitalSet: ReqUpdateHospitalSetParams){
  return request.put<any, null>('/admin/hosp/hospitalSet/update', hospitalSet);
}

/**
 * 根据id删除医院设置信息
 * @param id 医院设置信息的 ID
 * @returns  Promise<null>
 */
export function reqRemoveHospitalSet(id: number){
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
}

/** */
export function reqBatchRemoveHospitalSet(idList: React.Key[]){
  return request.delete('/admin/hosp/hospitalSet/batchRemove', {
    data: idList
  })
}